#ifndef V4L2CAMERA_HPP
#define V4L2CAMERA_HPP

#include "cbb_camera_comm.h"
#include "cbb_camera_type.h"
#include <linux/videodev2.h>
#include <string>

struct V4L2CameraConfig {
    std::string deviceName;
    int width;
    int height;
    int fps;
    uint32_t format;
};

class V4L2Camera {
  public:
    V4L2Camera(const V4L2CameraConfig &config);
    ~V4L2Camera();

    bool open();
    bool close();
    bool startCapture();
    bool stopCapture();
    bool captureFrame(CbbCameraFrame_t &frame, int timeout_ms);
    bool releaseFrame(CbbCameraFrame_t &frame);
    bool updateConfig(const V4L2CameraConfig &config);
    bool setConfig();

  private:
    bool m_isOpen = false;
    CameraHandle m_handle = nullptr;
    V4L2CameraConfig m_config = {0};
};

#endif // V4L2CAMERA_HPP